package com.huike.clues.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huike.clues.domain.TbRulePool;
import com.huike.clues.service.TbRulePoolService;
import com.huike.clues.mapper.TbRulePoolMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 93238
 * @description 针对表【tb_rule_pool(线索池规则)】的数据库操作Service实现
 * @createDate 2023-10-12 06:35:46
 */

/**
 * 线索池配置实现类
 */
@Service
public class TbRulePoolServiceImpl extends ServiceImpl<TbRulePoolMapper, TbRulePool>
        implements TbRulePoolService {

    /**
     * updateTbRulePool
     *
     * @param tbRulePool
     * @return
     */
    @Override
    public boolean updateTbRulePool(TbRulePool tbRulePool) {
        return this.lambdaUpdate()
                .eq(TbRulePool::getId, tbRulePool.getId())
                .set(ObjectUtil.isNotEmpty(tbRulePool.getLimitTime()), TbRulePool::getLimitTime, tbRulePool.getLimitTime())
                .set(ObjectUtil.isNotEmpty(tbRulePool.getWarnTime()), TbRulePool::getWarnTime, tbRulePool.getWarnTime())
                .set(ObjectUtil.isNotEmpty(tbRulePool.getRepeatGetTime()), TbRulePool::getRepeatGetTime, tbRulePool.getRepeatGetTime())
                .set(ObjectUtil.isNotEmpty(tbRulePool.getMaxNunmber()), TbRulePool::getMaxNunmber, tbRulePool.getMaxNunmber())
                .update();
    }

    /**
     * 获取规则基础信息type=0 线索 type=1 商机
     *
     * @param type
     * @return
     */
    @Override
    public List<TbRulePool> selectTbRulePool(Integer type) {
        return this.lambdaQuery()
                .eq(ObjectUtil.isNotEmpty(type), TbRulePool::getType, type)
                .list();
    }
}




